package cn.ym.basic.controller;

import cn.ym.basic.dto.LoginDto;
import cn.ym.basic.utils.AjaxResult;
import cn.ym.user.service.ILogininfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/***
 *  管理端的登录
 *  用户端的登录
 *
 */
@RestController

public class LoginController {

    @Autowired
    private ILogininfoService logininfoService;

    /**
     * 前台用户 登录接口
     * @param LoginDto
     * @return
     */
    @PostMapping("/login")
    public AjaxResult accountLogin(@RequestBody LoginDto LoginDto){
        Map<String,Object> map = logininfoService.accountLogin(LoginDto);

        return AjaxResult.me().setResultObj(map);
    }


    /**
     * 微信三方：微信登录接口
     * @param map
     * @return
     */
    @PostMapping("/login/wechat")
    public AjaxResult wechatLogin(@RequestBody Map<String,String> map){


        return logininfoService.wechatLogin(map);
    }




    /**
     * 微信三方：微信绑定接口
     * @param map
     * @return
     */
    @PostMapping("/login/wechat/binder")
    public AjaxResult wechatBinder(@RequestBody Map<String,String> map){


        return logininfoService.wechatBinder(map);
    }


}
